/**
 */
package org.mro.grib.model.files.secondEdition.products.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.mro.grib.model.files.secondEdition.products.ProductDefinitionTemplate42;
import org.mro.grib.model.files.secondEdition.products.ProductsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Product Definition Template42</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate42Impl#getDerivedForecast <em>Derived Forecast</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate42Impl#getNumberOfForecastsInEnsemble <em>Number Of Forecasts In Ensemble</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProductDefinitionTemplate42Impl extends ProductDefinitionTemplate40Impl implements ProductDefinitionTemplate42 {
	/**
	 * The default value of the '{@link #getDerivedForecast() <em>Derived Forecast</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDerivedForecast()
	 * @generated
	 * @ordered
	 */
	protected static final byte DERIVED_FORECAST_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getDerivedForecast() <em>Derived Forecast</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDerivedForecast()
	 * @generated
	 * @ordered
	 */
	protected byte derivedForecast = DERIVED_FORECAST_EDEFAULT;

	/**
	 * The default value of the '{@link #getNumberOfForecastsInEnsemble() <em>Number Of Forecasts In Ensemble</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfForecastsInEnsemble()
	 * @generated
	 * @ordered
	 */
	protected static final byte NUMBER_OF_FORECASTS_IN_ENSEMBLE_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getNumberOfForecastsInEnsemble() <em>Number Of Forecasts In Ensemble</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfForecastsInEnsemble()
	 * @generated
	 * @ordered
	 */
	protected byte numberOfForecastsInEnsemble = NUMBER_OF_FORECASTS_IN_ENSEMBLE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProductDefinitionTemplate42Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ProductsPackage.Literals.PRODUCT_DEFINITION_TEMPLATE42;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getDerivedForecast() {
		return derivedForecast;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDerivedForecast(byte newDerivedForecast) {
		byte oldDerivedForecast = derivedForecast;
		derivedForecast = newDerivedForecast;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE42__DERIVED_FORECAST, oldDerivedForecast, derivedForecast));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getNumberOfForecastsInEnsemble() {
		return numberOfForecastsInEnsemble;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNumberOfForecastsInEnsemble(byte newNumberOfForecastsInEnsemble) {
		byte oldNumberOfForecastsInEnsemble = numberOfForecastsInEnsemble;
		numberOfForecastsInEnsemble = newNumberOfForecastsInEnsemble;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE42__NUMBER_OF_FORECASTS_IN_ENSEMBLE, oldNumberOfForecastsInEnsemble, numberOfForecastsInEnsemble));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE42__DERIVED_FORECAST:
				return getDerivedForecast();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE42__NUMBER_OF_FORECASTS_IN_ENSEMBLE:
				return getNumberOfForecastsInEnsemble();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE42__DERIVED_FORECAST:
				setDerivedForecast((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE42__NUMBER_OF_FORECASTS_IN_ENSEMBLE:
				setNumberOfForecastsInEnsemble((Byte)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE42__DERIVED_FORECAST:
				setDerivedForecast(DERIVED_FORECAST_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE42__NUMBER_OF_FORECASTS_IN_ENSEMBLE:
				setNumberOfForecastsInEnsemble(NUMBER_OF_FORECASTS_IN_ENSEMBLE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE42__DERIVED_FORECAST:
				return derivedForecast != DERIVED_FORECAST_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE42__NUMBER_OF_FORECASTS_IN_ENSEMBLE:
				return numberOfForecastsInEnsemble != NUMBER_OF_FORECASTS_IN_ENSEMBLE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (derivedForecast: "); //$NON-NLS-1$
		result.append(derivedForecast);
		result.append(", numberOfForecastsInEnsemble: "); //$NON-NLS-1$
		result.append(numberOfForecastsInEnsemble);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.products.IProductDefinition#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) {
		super.initialise(buffer);
		derivedForecast = buffer.get();
		numberOfForecastsInEnsemble = buffer.get();
	}
	
} //ProductDefinitionTemplate42Impl
